package com.study.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.study.model.JqGridModel;
import com.study.model.User;
import com.study.service.UserService;

@Controller
public class SeeUserInfoController {
	@Autowired
	private UserService userService;
	
	
	@RequestMapping(value="/seeList") 
	public  JqGridModel list2( Integer page, Integer rows, Model model, HttpServletRequest request) {
		page = (page - 1) < 0 ? 0:(page - 1);
		Integer records = userService.countGroup();
		List<User> list = userService.selectGroup(page, rows);
		
		// 查到数据后封装为显示所需要的数据模型

		// 计算总页数
		int total = records / rows + (records % rows > 0 ? 1 : 0);
		JqGridModel grid = new JqGridModel(page, total, records, list);
		return grid;

	}
}
